package model

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

type Goods struct {
	gorm.Model
	GoodsId      int64  `gorm:"type:int(11);not null;comment:商品id"`
	GoodsName    string `gorm:"type:varchar(50);not null;comment:商品名称"`
	GoodsPrice   int64  `gorm:"type:int(64);not null;comment:商品价格"`
	GoodsNum     int64  `gorm:"type:int(11);comment:商品数量"`
	GoodsAddress string `gorm:"type:varchar(50);not null;comment:商品地址"`
}

func (u *Goods) CreateGoods() error {
	return mysql.WithMysql(func(db *gorm.DB) error {
		return db.Create(u).Error
	})
}
func (u *Goods) GoodsList() error {
	return mysql.WithMysql(func(db *gorm.DB) error {
		return db.Where("goods_id =?", u.GoodsId).Find(u).Error
	})
}
